/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package knowlegeBase;

import java.util.ArrayList;
import java.util.Iterator;
import robosym.visual.Barrier;
import robosym.visual.emulator.Map;

/**
 *
 * @author Lucky
 */
public class KnowlegeBase {
    private ArrayList <Barrier> barriers;
    private static KnowlegeBase kb = null;

    public static KnowlegeBase getInstance(){
        if(kb == null)
            kb = new KnowlegeBase();
        return kb;
    }

    public void addBarrier(Barrier barrier){
        if(!barriers.contains(barrier))
            getBarriers().add(barrier);
    }

    public void addBarriers(ArrayList <Barrier> barriers){
        Iterator it = barriers.iterator();
        while(it.hasNext()){
            Barrier barr = (Barrier) it.next();
            addBarrier(barr);
        }
    }

    /**
     * @return the barriers
     */
    public ArrayList<Barrier> getBarriers() {
        return barriers;
    }

    public void setBarriersFromMap(){
        barriers = Map.getInstance().getBarriers();
    }

}
